package com.yqg.protection.mapper;

import com.github.yulichang.base.MPJBaseMapper;
import com.yqg.protection.controller.dto.UserPasswordDTO;
import com.yqg.protection.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zxf
 * @since 2024-01-01
 */
@Mapper
public interface UserMapper extends MPJBaseMapper<User> {

    List<User> getUsersByOrganId(Integer pageNum, Integer pageSize, Long organizationId, Long userId, String keyWord, Integer role, Integer level);

    Long getUsersCountByOrganId(Long organizationId, Long userId, String keyWord, Integer role, Integer level);

    @Update("update user set password = #{newPass} where id = #{userId} and password = #{password} and is_delete = 0")
    int updatePassword(UserPasswordDTO userPasswordDTO);

    //重置密码————重置为默认密码123456
    @Update("update user set password = #{original_password},update_time = #{date} where id = #{id} and is_delete = 0")
    int resetPwd(@Param("id") int id, @Param("original_password") String password, @Param("date") Date date);

    User getLoginUser(String username, String password);

    User getUserById(Long userId);

    List<User> listUsersByIds(Collection<Long> userIds);

    List<Long> getonlineUsersByOrganId(Integer level, Long country, Long scTeam, Long fcTeam, Long fbTeam, Long community, Long building, Long unit, Long floor, Long room, Set<Long> userIds, Long clientId);

    List<Long> getAllUsersByOrganId(Integer level, Long country, Long scTeam, Long fcTeam, Long fbTeam, Long community, Long building, Long unit, Long floor, Long room, Long clientId);

    List<User> exportData(Integer level, Long organizationId, Long userId, String keyWord, Integer role);
}
